<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;

var frame;
function test() {
    frame = document.getElementById('frame');
    var doc = frame.contentDocument.open();
    var htmlString = "Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> \
                      Lots of text</br>Lots of text</br> ";

    doc.write(htmlString);
    doc.close();
    frame.contentDocument.body.style.height = "2000px";

    if (window.eventSender) {
        var xPoint = frame.scrollLeft + 100;
        var yPoint = frame.scrollTop + 100;
        eventSender.dragMode = false;
        eventSender.mouseMoveTo(xPoint, yPoint);
        eventSender.mouseDown();
        eventSender.mouseMoveTo(xPoint, frame.offsetHeight + 100);
        setTimeout(testAutoScroll, 1500);
        eventSender.keyDown('a');
    } else {
        debug("Test manually that scrolling does not stop if we press a key while autoscroll is happening.");
    }
}

function testAutoScroll() {
    shouldBe('frame.contentDocument.scrollingElement.scrollTop + frame.clientHeight', 'frame.contentDocument.scrollingElement.scrollHeight');
    finishJSTest();
}

successfullyParsed = true;
</script> 
</head>
<body onload="test()">
<iframe id="frame" style="height: 400px;" frameborder="0"></iframe>
<div id="console"></div>
</body>
</html>
